package com.example.service.group.controller;


import com.example.common.ResponseVO;
import com.example.service.group.model.req.*;
import com.example.service.group.service.ImGroupMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: lld
 * @version: 1.0
 */
@RestController
@RequestMapping("v1/group/member")
@Api(tags = "群聊成员相关接口")
public class ImGroupMemberController {

    @Autowired
    ImGroupMemberService groupMemberService;

    @PostMapping("/importGroupMember")
    @ApiOperation("导入群聊成员")
    public ResponseVO importGroupMember(@RequestBody @Validated ImportGroupMemberReq req)  { //, Integer appId, String identifier
//        req.setAppId(appId);
//        req.setOperater(identifier);
        return groupMemberService.importGroupMember(req);
    }

    @PostMapping("/add")
    @ApiOperation("添加群聊成员")
    public ResponseVO addMember(@RequestBody @Validated AddGroupMemberReq req)  { //, Integer appId, String identifier
//        req.setAppId(appId);
//        req.setOperater(identifier);
        return groupMemberService.addMember(req);
    }

    @PostMapping("/remove")
    @ApiOperation("移除群聊成员")
    public ResponseVO removeMember(@RequestBody @Validated RemoveGroupMemberReq req)  { //，Integer appId, String identifier
//        req.setAppId(appId);
//        req.setOperater(identifier);
        return groupMemberService.removeMember(req);
    }


    @PostMapping("exit")
    @ApiOperation("退出群聊")
    public ResponseVO exit(String groupId, Integer appId, String memberId){
        return groupMemberService.exitGrop(groupId,appId,memberId);
    }

    @PostMapping("/update")
    @ApiOperation("修改群聊成员资料")
    public ResponseVO updateGroupMember(@RequestBody @Validated UpdateGroupMemberReq req )  { // ，Integer appId, String identifier
//        req.setAppId(appId);
//        req.setOperater(identifier);
        return groupMemberService.updateGroupMember(req);
    }

    @PostMapping("/speak")
    @ApiOperation("对群内成员的禁言")
    public ResponseVO speak(@RequestBody @Validated SpeaMemberReq req)  { //, Integer appId, String identifier
//        req.setAppId(appId);
//        req.setOperater(identifier);
        return groupMemberService.speak(req);
    }

}
